package com.shoulei.designpattern.compositePattern;

import java.security.spec.ECField;

/**
 * @ClassName:CompositePatternDemo
 * @Descrition:
 * @Author:shoulei
 * @Date:2019/4/14 11:43
 * @Verson:
 */
public class CompositePatternDemo {
    public static void main(String[] args) {
        Employee ceo = new Employee("zhangsan","CEO",2000000);
        Employee headSales = new Employee("lisi","Sales",200000);
        Employee headMarking = new Employee("wangwu","marking",100000);
        Employee clerk1 = new Employee("zhou","Marking",2000);
        Employee clerk2 = new Employee("wu","Marking",2300);
        Employee sales1 = new Employee("zheng","Sales",3000);
        Employee sales2 = new Employee("wang","Sales",4000);
        ceo.add(headMarking);
        ceo.add(headSales);
        headMarking.add(clerk1);
        headMarking.add(clerk2);
        headSales.add(sales1);
        headSales.add(sales2);

        for(Employee headEmployee:ceo.getSubordinates()){
            System.out.println(headEmployee.toString());
            for(Employee employee : headEmployee.getSubordinates()){
                System.out.println(employee.toString());
            }
        }
    }
}
